package come.my.test;
    //public class day17 {
//    public static void main(String[] args) {
    //创建的对象只能用一次点燃方法
//        new match(){
//            @Override
//          public void matching() {
//              System.out.println("火柴燃烧");
//          }
//      }.matching();
//    }
//
//}
//interface match{
//     void matching();
//}
/*public class day17{
    public static void main(String[] args) {
        //跳动的心脏
        Person person = new Person();
    }

}
class Person{
    class Heart{
        public void hearting(){
            System.out.println("心脏不停的跳动");
        }
    }

    public Person() {
        Heart heart = new Heart();
        heart.hearting();

    }
}
*/
/*public class day17 {
    public static void main(String[] args) {
        Person person = new Person();
        person.eat(new Fruit(){
            @Override
            public String getName() {
                return "苹果";
            }
        });
    }
}
abstract class Fruit{
   public  abstract String getName();
}
 class Person {
    public  void eat(Fruit  fruit){
        System.out.println("我吃了"+fruit.getName());
    }
}*/
    public class day17{
        public static void main(String[] args) {
            new Moveable(){

                @Override
                public void run() {
                    System.out.println("小狗向前跑");
                }
            }.run();
        }
    }
    interface Moveable{
        void run();
    }

